package com.jinkeen.xiaxie.base

import android.app.Application
import android.content.Intent
import android.os.Build
import androidx.work.Configuration
import com.hyphenate.chat.EMOptions
import com.jinkeen.xiaxie.BuildConfig
import com.jinkeen.xiaxie.service.CancelNoticeService
import com.jinkeen.xiaxie.service.WhiteService

/**
 * @description:
 * @author whz
 * @date 2021/6/3 17:12
 * @version 1.0
 */

class MyApplication : Application(), Configuration.Provider {


    companion object {
        var instance: MyApplication? = null
    }


    override fun onCreate() {
        super.onCreate()
        instance = this
        var options = EMOptions()
        var service = Intent(this, WhiteService::class.java)
        service.putExtra("whiteService", "sassa")
        var service2 = Intent(this, CancelNoticeService::class.java)
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
//            startForegroundService(service)
//            startForegroundService(service2)
        } else {
//            startService(service)
//            startService(service2)
        }
    }

    override fun getWorkManagerConfiguration() = Configuration.Builder()
        .setMinimumLoggingLevel(if (BuildConfig.DEBUG) android.util.Log.DEBUG else android.util.Log.ERROR)
        .build()
}